package com.oromwin.repos.server.request.media;

import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;

import org.apache.commons.logging.Log;

import com.oromwin.repos.server.request.Request;
import com.oromwin.repos.common.Logger;
import com.oromwin.repos.common.ReposException;
import com.oromwin.repos.common.helper.IOHelper;

public class CreateMediaRequest implements Request {
    private Log log = Logger.getLog(CreateMediaRequest.class);
    private String VolumeId = null;
    private File MediaPath = null;
    private long MediaMaxBytes = 0L;

    public CreateMediaRequest(String volumeId, File mediaPath, long mediaMaxBytes) {
        VolumeId = volumeId;
        MediaPath = mediaPath;
        MediaMaxBytes = mediaMaxBytes;
    }

    public void send(DataOutputStream dos) throws ReposException {
        try {
            IOHelper.writeUTF8(dos, this.getClass().getName());
            IOHelper.writeUTF8(dos, VolumeId);
            IOHelper.writeUTF8(dos, MediaPath.toString());
            dos.writeLong(MediaMaxBytes);
            dos.flush();
        } catch (IOException e) {
            throw ReposException.create(log, e);
        }
    }
}
